
# HOST_BIN_DIR := /home/celticzy/nuvoton/nuc980/nuc980_bsp5/buildroot/output/host/usr/bin/
# CROSS_COMPILE_PREFIX := arm-linux-

HOST_BIN_DIR :=
CROSS_COMPILE_PREFIX :=

V := 0
ifeq (${V}, 1)
        Q:=
else
        Q:=@
endif

CC := $(HOST_BIN_DIR)$(CROSS_COMPILE_PREFIX)gcc
CXX := $(HOST_BIN_DIR)$(CROSS_COMPILE_PREFIX)g++
PKGCONFIG := $(HOST_BIN_DIR)pkg-config

CFLAGS := $(shell $(PKGCONFIG) --cflags glib-2.0 gobject-2.0 gio-unix-2.0) -Wall
LFLAGS := $(shell $(PKGCONFIG) --libs glib-2.0 gobject-2.0 gio-unix-2.0) -Wall

all: server client
	@echo "Over !!!"

battery.h battery.c: battery.xml
	@echo "GEN battery.c battery.h ..."
	$(Q)$(HOST_BIN_DIR)gdbus-codegen --generate-c-code=battery --c-namespace battery \
		--interface-prefix cygia.battery. battery.xml

%.o: %.c battery.h
	@echo "CC  $@ ..."
	$(Q)$(CC) -c $< $(CFLAGS) -o $@

server: server.o battery.o
	@echo "LK  $@ ..."
	$(Q)$(CC) $^ $(LFLAGS) -o $@

client: client.o battery.o
	@echo "LK  $@ ..."
	$(Q)$(CC) $^ $(LFLAGS) -o $@

clean:
	$(Q)rm *.o server client battery.c battery.h -f
